home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 3222 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.5 KB

  1. Path: s02.pavilion.co.uk!usenet
  2. From: AJRobb@pavilion.co.uk (Andy J Robb)
  3. Newsgroups: comp.lang.java,comp.lang.c,comp.lang.c++
  4. Subject: Re: Correct mod/rem (was: Problem with % (remainder) operator
  5. Date: Mon, 22 Jan 1996 22:11:18 GMT
  6. Organization: Pavilion Internet plc
  7. Message-ID: <4e120p$p3g@s02.pavilion.co.uk>
  8. References: <4dc86s$gha@news.xs4all.nl> <4d8hnd$74h@news.xs4all.nl> <443322587wnr@almide.demon.co.uk> <142091149wnr@almide.demon.co.uk> <4dguci$le3@news.ox.ac.uk> <hbaker-2201961022380001@10.0.2.15>
  9. NNTP-Posting-Host: poolc05.pavilion.co.uk
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. hbaker@netcom.com (Henry Baker) wrote:
  13.  
  14. Personally, I agree - rounding towards minus infinity is preferred.
  15. Generally, the IEEE seem to prefer bank rounding as the default.
  16. This means that the value zero means:
  17.     -0.5 <= answer <= 0.5
  18. the value 1 means
  19.      0.5 <  answer <  1.5
  20. the value 2 means
  21.      1.5 <= answer <= 2.5
  22.  
  23. Thus 3/-2 == -3/2 == -(3/2) == -(-3/-2) == -2
  24.      2/-3 == -2/3 == -(2/3) == -(-2/-3) == -1
  25.  
  26. ISO/ANSI only guarantee that x/y*y + x%y = x (as you know).  The
  27. remainder should be calculated after bank rounding the quotient.
  28.  
  29. Regards,
  30.  
  31. -----BEGIN PGP PUBLIC KEY BLOCK-----
  32. Version: 2.6.2i
  33.  
  34. mQCNAy/MpRwAAAEEAOt6uBYqT8yv9EmqNhK8m6v+bYi8QjnGW3Bo6iU1gsMj5pa6
  35. MHgq99c8deADbE3cbJ6uZS9v5pZE3WCf6HCQjlB5iULA5RZzMdAumd/WUzuL9UT3
  36. B44D9EqqFIL79FlYb56v4oKFqFp1/J2bIpYUwnUvabGzGjdLrpPl4P16x9sNAAUR
  37. tCNBbmR5IEogUm9iYiA8QUpSb2JiQHBhdmlsaW9uLmNvLnVrPrQhQW5keSBSb2Ji
  38. IDxBSlJvYmJAcGF2aWxpb24uY28udWs+
  39. =/wVD
  40. -----END PGP PUBLIC KEY BLOCK-----
  41.  
  42.